<?xml version="1.0" encoding="ascii"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>web2py.gluon.utils</title>
  <link rel="stylesheet" href="epydoc.css" type="text/css" />
  <script type="text/javascript" src="epydoc.js"></script>
</head>

<body bgcolor="white" text="black" link="blue" vlink="#204080"
      alink="#204080">
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="web2py.gluon-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Project homepage -->
      <th class="navbar" align="right" width="100%">
        <table border="0" cellpadding="0" cellspacing="0">
          <tr><th class="navbar" align="center"
            ><a class="navbar" target="_top" href="http://www.web2py.com">web2py Web Framework</a></th>
          </tr></table></th>
  </tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
  <tr valign="top">
    <td width="100%">
      <span class="breadcrumbs">
        Package&nbsp;web2py ::
        <a href="web2py.gluon-module.html">Package&nbsp;gluon</a> ::
        Module&nbsp;utils
      </span>
    </td>
    <td>
      <table cellpadding="0" cellspacing="0">
        <!-- hide/show private -->
        <tr><td align="right"><span class="options">[<a href="javascript:void(0);" class="privatelink"
    onclick="toggle_private();">hide&nbsp;private</a>]</span></td></tr>
        <tr><td align="right"><span class="options"
            >[<a href="frames.html" target="_top">frames</a
            >]&nbsp;|&nbsp;<a href="web2py.gluon.utils-pysrc.html"
            target="_top">no&nbsp;frames</a>]</span></td></tr>
      </table>
    </td>
  </tr>
</table>
<h1 class="epydoc">Source Code for <a href="web2py.gluon.utils-module.html">Module web2py.gluon.utils</a></h1>
<pre class="py-src">
<a name="L1"></a><tt class="py-lineno"> 1</tt>  <tt class="py-line"><tt class="py-comment">#!/usr/bin/env python</tt> </tt>
<a name="L2"></a><tt class="py-lineno"> 2</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment"># -*- coding: utf-8 -*-</tt> </tt>
<a name="L3"></a><tt class="py-lineno"> 3</tt>  <tt class="py-line"><tt class="py-comment"></tt> </tt>
<a name="L4"></a><tt class="py-lineno"> 4</tt>  <tt class="py-line"><tt class="py-docstring">"""</tt> </tt>
<a name="L5"></a><tt class="py-lineno"> 5</tt>  <tt class="py-line"><tt class="py-docstring">This file is part of web2py Web Framework (Copyrighted, 2007-2010).</tt> </tt>
<a name="L6"></a><tt class="py-lineno"> 6</tt>  <tt class="py-line"><tt class="py-docstring">Developed by Massimo Di Pierro &lt;mdipierro@cs.depaul.edu&gt;.</tt> </tt>
<a name="L7"></a><tt class="py-lineno"> 7</tt>  <tt class="py-line"><tt class="py-docstring">License: GPL v2</tt> </tt>
<a name="L8"></a><tt class="py-lineno"> 8</tt>  <tt class="py-line"><tt class="py-docstring">"""</tt> </tt>
<a name="L9"></a><tt class="py-lineno"> 9</tt>  <tt class="py-line"> </tt>
<a name="L10"></a><tt class="py-lineno">10</tt>  <tt class="py-line"><tt class="py-keyword">import</tt> <tt class="py-name">hashlib</tt> </tt>
<a name="L11"></a><tt class="py-lineno">11</tt>  <tt class="py-line"><tt class="py-keyword">import</tt> <tt class="py-name">uuid</tt> </tt>
<a name="L12"></a><tt class="py-lineno">12</tt>  <tt class="py-line"><tt class="py-keyword">import</tt> <tt class="py-name">random</tt> </tt>
<a name="L13"></a><tt class="py-lineno">13</tt>  <tt class="py-line"><tt class="py-keyword">import</tt> <tt class="py-name">os</tt> </tt>
<a name="L14"></a><tt class="py-lineno">14</tt>  <tt class="py-line"><tt class="py-keyword">import</tt> <tt id="link-0" class="py-name" targets="Variable web2py.gluon.rewrite.thread=web2py.gluon.rewrite-module.html#thread,Variable web2py.gluon.sql.thread=web2py.gluon.sql-module.html#thread,Variable web2py.gluon.thread_local_singleton.Singleton.thread=web2py.gluon.thread_local_singleton.Singleton-class.html#thread"><a title="web2py.gluon.rewrite.thread
web2py.gluon.sql.thread
web2py.gluon.thread_local_singleton.Singleton.thread" class="py-name" href="#" onclick="return doclink('link-0', 'thread', 'link-0');">thread</a></tt> </tt>
<a name="L15"></a><tt class="py-lineno">15</tt>  <tt class="py-line"><tt class="py-keyword">import</tt> <tt class="py-name">time</tt> </tt>
<a name="L16"></a><tt class="py-lineno">16</tt>  <tt class="py-line"> </tt>
<a name="md5_hash"></a><div id="md5_hash-def"><a name="L17"></a><tt class="py-lineno">17</tt> <a class="py-toggle" href="#" id="md5_hash-toggle" onclick="return toggle('md5_hash');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="web2py.gluon.utils-module.html#md5_hash">md5_hash</a><tt class="py-op">(</tt><tt class="py-param">text</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="md5_hash-collapsed" style="display:none;" pad="++" indent="++++"></div><div id="md5_hash-expanded"><a name="L18"></a><tt class="py-lineno">18</tt>  <tt class="py-line">    <tt class="py-docstring">""" Generate a md5 hash with the given text """</tt> </tt>
<a name="L19"></a><tt class="py-lineno">19</tt>  <tt class="py-line"> </tt>
<a name="L20"></a><tt class="py-lineno">20</tt>  <tt class="py-line">    <tt class="py-keyword">return</tt> <tt class="py-name">hashlib</tt><tt class="py-op">.</tt><tt class="py-name">md5</tt><tt class="py-op">(</tt><tt class="py-name">text</tt><tt class="py-op">)</tt><tt class="py-op">.</tt><tt class="py-name">hexdigest</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
</div><a name="L21"></a><tt class="py-lineno">21</tt>  <tt class="py-line"> </tt>
<a name="L22"></a><tt class="py-lineno">22</tt>  <tt class="py-line"> </tt>
<a name="hash"></a><div id="hash-def"><a name="L23"></a><tt class="py-lineno">23</tt> <a class="py-toggle" href="#" id="hash-toggle" onclick="return toggle('hash');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="web2py.gluon.utils-module.html#hash">hash</a><tt class="py-op">(</tt><tt class="py-param">text</tt><tt class="py-op">,</tt> <tt class="py-param">digest_alg</tt> <tt class="py-op">=</tt> <tt class="py-string">'md5'</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="hash-collapsed" style="display:none;" pad="++" indent="++++"></div><div id="hash-expanded"><a name="L24"></a><tt class="py-lineno">24</tt>  <tt class="py-line">    <tt class="py-docstring">"""</tt> </tt>
<a name="L25"></a><tt class="py-lineno">25</tt>  <tt class="py-line"><tt class="py-docstring">    Generates hash with the given text using the specified</tt> </tt>
<a name="L26"></a><tt class="py-lineno">26</tt>  <tt class="py-line"><tt class="py-docstring">    digest hashing algorithm</tt> </tt>
<a name="L27"></a><tt class="py-lineno">27</tt>  <tt class="py-line"><tt class="py-docstring">    """</tt> </tt>
<a name="L28"></a><tt class="py-lineno">28</tt>  <tt class="py-line">    <tt class="py-keyword">if</tt> <tt class="py-keyword">not</tt> <tt class="py-name">isinstance</tt><tt class="py-op">(</tt><tt class="py-name">digest_alg</tt><tt class="py-op">,</tt><tt class="py-name">str</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
<a name="L29"></a><tt class="py-lineno">29</tt>  <tt class="py-line">        <tt class="py-name">h</tt> <tt class="py-op">=</tt> <tt class="py-name">digest_alg</tt><tt class="py-op">(</tt><tt class="py-name">text</tt><tt class="py-op">)</tt> </tt>
<a name="L30"></a><tt class="py-lineno">30</tt>  <tt class="py-line">    <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L31"></a><tt class="py-lineno">31</tt>  <tt class="py-line">        <tt class="py-name">h</tt> <tt class="py-op">=</tt> <tt class="py-name">hashlib</tt><tt class="py-op">.</tt><tt class="py-name">new</tt><tt class="py-op">(</tt><tt class="py-name">digest_alg</tt><tt class="py-op">)</tt> </tt>
<a name="L32"></a><tt class="py-lineno">32</tt>  <tt class="py-line">        <tt class="py-name">h</tt><tt class="py-op">.</tt><tt id="link-1" class="py-name" targets="Method web2py.gluon.dal.Set.update()=web2py.gluon.dal.Set-class.html#update,Method web2py.gluon.html.DIV.update()=web2py.gluon.html.DIV-class.html#update,Method web2py.gluon.sql.Set.update()=web2py.gluon.sql.Set-class.html#update,Method web2py.gluon.thread_local_singleton.Singleton.update()=web2py.gluon.thread_local_singleton.Singleton-class.html#update,Method web2py.gluon.tools.Crud.update()=web2py.gluon.tools.Crud-class.html#update,Method web2py.gluon.widget.web2pyDialog.update()=web2py.gluon.widget.web2pyDialog-class.html#update"><a title="web2py.gluon.dal.Set.update
web2py.gluon.html.DIV.update
web2py.gluon.sql.Set.update
web2py.gluon.thread_local_singleton.Singleton.update
web2py.gluon.tools.Crud.update
web2py.gluon.widget.web2pyDialog.update" class="py-name" href="#" onclick="return doclink('link-1', 'update', 'link-1');">update</a></tt><tt class="py-op">(</tt><tt class="py-name">text</tt><tt class="py-op">)</tt> </tt>
<a name="L33"></a><tt class="py-lineno">33</tt>  <tt class="py-line">    <tt class="py-keyword">return</tt> <tt class="py-name">h</tt><tt class="py-op">.</tt><tt class="py-name">hexdigest</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
</div><a name="L34"></a><tt class="py-lineno">34</tt>  <tt class="py-line"> </tt>
<a name="get_digest"></a><div id="get_digest-def"><a name="L35"></a><tt class="py-lineno">35</tt> <a class="py-toggle" href="#" id="get_digest-toggle" onclick="return toggle('get_digest');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="web2py.gluon.utils-module.html#get_digest">get_digest</a><tt class="py-op">(</tt><tt class="py-param">value</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="get_digest-collapsed" style="display:none;" pad="++" indent="++++"></div><div id="get_digest-expanded"><a name="L36"></a><tt class="py-lineno">36</tt>  <tt class="py-line">    <tt class="py-docstring">"""</tt> </tt>
<a name="L37"></a><tt class="py-lineno">37</tt>  <tt class="py-line"><tt class="py-docstring">    Returns a hashlib digest algorithm from a string</tt> </tt>
<a name="L38"></a><tt class="py-lineno">38</tt>  <tt class="py-line"><tt class="py-docstring">    """</tt> </tt>
<a name="L39"></a><tt class="py-lineno">39</tt>  <tt class="py-line">    <tt class="py-keyword">if</tt> <tt class="py-keyword">not</tt> <tt class="py-name">isinstance</tt><tt class="py-op">(</tt><tt class="py-name">value</tt><tt class="py-op">,</tt><tt class="py-name">str</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
<a name="L40"></a><tt class="py-lineno">40</tt>  <tt class="py-line">        <tt class="py-keyword">return</tt> <tt class="py-name">value</tt> </tt>
<a name="L41"></a><tt class="py-lineno">41</tt>  <tt class="py-line">    <tt class="py-name">value</tt> <tt class="py-op">=</tt> <tt class="py-name">value</tt><tt class="py-op">.</tt><tt id="link-2" class="py-name" targets="Method web2py.gluon.dal.Field.lower()=web2py.gluon.dal.Field-class.html#lower,Method web2py.gluon.sql.Field.lower()=web2py.gluon.sql.Field-class.html#lower"><a title="web2py.gluon.dal.Field.lower
web2py.gluon.sql.Field.lower" class="py-name" href="#" onclick="return doclink('link-2', 'lower', 'link-2');">lower</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L42"></a><tt class="py-lineno">42</tt>  <tt class="py-line">    <tt class="py-keyword">if</tt> <tt class="py-name">value</tt> <tt class="py-op">==</tt> <tt class="py-string">"md5"</tt><tt class="py-op">:</tt> </tt>
<a name="L43"></a><tt class="py-lineno">43</tt>  <tt class="py-line">        <tt class="py-keyword">return</tt> <tt class="py-name">hashlib</tt><tt class="py-op">.</tt><tt class="py-name">md5</tt> </tt>
<a name="L44"></a><tt class="py-lineno">44</tt>  <tt class="py-line">    <tt class="py-keyword">elif</tt> <tt class="py-name">value</tt> <tt class="py-op">==</tt> <tt class="py-string">"sha1"</tt><tt class="py-op">:</tt> </tt>
<a name="L45"></a><tt class="py-lineno">45</tt>  <tt class="py-line">        <tt class="py-keyword">return</tt> <tt class="py-name">hashlib</tt><tt class="py-op">.</tt><tt class="py-name">sha1</tt> </tt>
<a name="L46"></a><tt class="py-lineno">46</tt>  <tt class="py-line">    <tt class="py-keyword">elif</tt> <tt class="py-name">value</tt> <tt class="py-op">==</tt> <tt class="py-string">"sha224"</tt><tt class="py-op">:</tt> </tt>
<a name="L47"></a><tt class="py-lineno">47</tt>  <tt class="py-line">        <tt class="py-keyword">return</tt> <tt class="py-name">hashlib</tt><tt class="py-op">.</tt><tt class="py-name">sha224</tt> </tt>
<a name="L48"></a><tt class="py-lineno">48</tt>  <tt class="py-line">    <tt class="py-keyword">elif</tt> <tt class="py-name">value</tt> <tt class="py-op">==</tt> <tt class="py-string">"sha256"</tt><tt class="py-op">:</tt> </tt>
<a name="L49"></a><tt class="py-lineno">49</tt>  <tt class="py-line">        <tt class="py-keyword">return</tt> <tt class="py-name">hashlib</tt><tt class="py-op">.</tt><tt class="py-name">sha256</tt> </tt>
<a name="L50"></a><tt class="py-lineno">50</tt>  <tt class="py-line">    <tt class="py-keyword">elif</tt> <tt class="py-name">value</tt> <tt class="py-op">==</tt> <tt class="py-string">"sha384"</tt><tt class="py-op">:</tt> </tt>
<a name="L51"></a><tt class="py-lineno">51</tt>  <tt class="py-line">        <tt class="py-keyword">return</tt> <tt class="py-name">hashlib</tt><tt class="py-op">.</tt><tt class="py-name">sha384</tt> </tt>
<a name="L52"></a><tt class="py-lineno">52</tt>  <tt class="py-line">    <tt class="py-keyword">elif</tt> <tt class="py-name">value</tt> <tt class="py-op">==</tt> <tt class="py-string">"sha512"</tt><tt class="py-op">:</tt> </tt>
<a name="L53"></a><tt class="py-lineno">53</tt>  <tt class="py-line">        <tt class="py-keyword">return</tt> <tt class="py-name">hashlib</tt><tt class="py-op">.</tt><tt class="py-name">sha512</tt> </tt>
<a name="L54"></a><tt class="py-lineno">54</tt>  <tt class="py-line">    <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L55"></a><tt class="py-lineno">55</tt>  <tt class="py-line">        <tt class="py-keyword">raise</tt> <tt class="py-name">ValueError</tt><tt class="py-op">(</tt><tt class="py-string">"Invalid digest algorithm"</tt><tt class="py-op">)</tt> </tt>
</div><a name="L56"></a><tt class="py-lineno">56</tt>  <tt class="py-line"> </tt>
<a name="L57"></a><tt class="py-lineno">57</tt>  <tt class="py-line"><tt id="link-3" class="py-name" targets="Variable web2py.gluon.utils.web2py_uuid_locker=web2py.gluon.utils-module.html#web2py_uuid_locker"><a title="web2py.gluon.utils.web2py_uuid_locker" class="py-name" href="#" onclick="return doclink('link-3', 'web2py_uuid_locker', 'link-3');">web2py_uuid_locker</a></tt> <tt class="py-op">=</tt> <tt id="link-4" class="py-name"><a title="web2py.gluon.rewrite.thread
web2py.gluon.sql.thread
web2py.gluon.thread_local_singleton.Singleton.thread" class="py-name" href="#" onclick="return doclink('link-4', 'thread', 'link-0');">thread</a></tt><tt class="py-op">.</tt><tt class="py-name">allocate_lock</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L58"></a><tt class="py-lineno">58</tt>  <tt class="py-line"><tt id="link-5" class="py-name" targets="Variable web2py.gluon.utils.node_id=web2py.gluon.utils-module.html#node_id"><a title="web2py.gluon.utils.node_id" class="py-name" href="#" onclick="return doclink('link-5', 'node_id', 'link-5');">node_id</a></tt> <tt class="py-op">=</tt> <tt class="py-name">uuid</tt><tt class="py-op">.</tt><tt class="py-name">getnode</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L59"></a><tt class="py-lineno">59</tt>  <tt class="py-line"><tt id="link-6" class="py-name" targets="Variable web2py.gluon.utils.milliseconds=web2py.gluon.utils-module.html#milliseconds"><a title="web2py.gluon.utils.milliseconds" class="py-name" href="#" onclick="return doclink('link-6', 'milliseconds', 'link-6');">milliseconds</a></tt> <tt class="py-op">=</tt> <tt class="py-name">int</tt><tt class="py-op">(</tt><tt class="py-name">time</tt><tt class="py-op">.</tt><tt class="py-name">time</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> <tt class="py-op">*</tt> <tt class="py-number">1e3</tt><tt class="py-op">)</tt> </tt>
<a name="L60"></a><tt class="py-lineno">60</tt>  <tt class="py-line"> </tt>
<a name="rotate"></a><div id="rotate-def"><a name="L61"></a><tt class="py-lineno">61</tt> <a class="py-toggle" href="#" id="rotate-toggle" onclick="return toggle('rotate');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="web2py.gluon.utils-module.html#rotate">rotate</a><tt class="py-op">(</tt><tt class="py-param">i</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="rotate-collapsed" style="display:none;" pad="++" indent="++++"></div><div id="rotate-expanded"><a name="L62"></a><tt class="py-lineno">62</tt>  <tt class="py-line">    <tt class="py-name">a</tt> <tt class="py-op">=</tt> <tt class="py-name">random</tt><tt class="py-op">.</tt><tt class="py-name">randrange</tt><tt class="py-op">(</tt><tt class="py-number">256</tt><tt class="py-op">)</tt> </tt>
<a name="L63"></a><tt class="py-lineno">63</tt>  <tt class="py-line">    <tt id="link-7" class="py-name" targets="Function web2py.gluon.rocket.b()=web2py.gluon.rocket-module.html#b"><a title="web2py.gluon.rocket.b" class="py-name" href="#" onclick="return doclink('link-7', 'b', 'link-7');">b</a></tt> <tt class="py-op">=</tt> <tt class="py-op">(</tt><tt id="link-8" class="py-name"><a title="web2py.gluon.utils.node_id" class="py-name" href="#" onclick="return doclink('link-8', 'node_id', 'link-5');">node_id</a></tt> <tt class="py-op">&gt;&gt;</tt> <tt class="py-number">4</tt><tt class="py-op">*</tt><tt class="py-name">i</tt><tt class="py-op">)</tt> <tt class="py-op">%</tt> <tt class="py-number">256</tt> </tt>
<a name="L64"></a><tt class="py-lineno">64</tt>  <tt class="py-line">    <tt class="py-name">c</tt> <tt class="py-op">=</tt> <tt class="py-op">(</tt><tt id="link-9" class="py-name"><a title="web2py.gluon.utils.milliseconds" class="py-name" href="#" onclick="return doclink('link-9', 'milliseconds', 'link-6');">milliseconds</a></tt> <tt class="py-op">&gt;&gt;</tt> <tt class="py-number">4</tt><tt class="py-op">*</tt><tt class="py-name">i</tt><tt class="py-op">)</tt> <tt class="py-op">%</tt> <tt class="py-number">256</tt> </tt>
<a name="L65"></a><tt class="py-lineno">65</tt>  <tt class="py-line">    <tt class="py-keyword">return</tt> <tt class="py-op">(</tt><tt class="py-name">a</tt> <tt class="py-op">+</tt> <tt id="link-10" class="py-name"><a title="web2py.gluon.rocket.b" class="py-name" href="#" onclick="return doclink('link-10', 'b', 'link-7');">b</a></tt> <tt class="py-op">+</tt> <tt class="py-name">c</tt><tt class="py-op">)</tt> <tt class="py-op">%</tt> <tt class="py-number">256</tt> </tt>
</div><a name="L66"></a><tt class="py-lineno">66</tt>  <tt class="py-line"> </tt>
<a name="web2py_uuid"></a><div id="web2py_uuid-def"><a name="L67"></a><tt class="py-lineno">67</tt> <a class="py-toggle" href="#" id="web2py_uuid-toggle" onclick="return toggle('web2py_uuid');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="web2py.gluon.utils-module.html#web2py_uuid">web2py_uuid</a><tt class="py-op">(</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="web2py_uuid-collapsed" style="display:none;" pad="++" indent="++++"></div><div id="web2py_uuid-expanded"><a name="L68"></a><tt class="py-lineno">68</tt>  <tt class="py-line">    <tt id="link-11" class="py-name"><a title="web2py.gluon.utils.web2py_uuid_locker" class="py-name" href="#" onclick="return doclink('link-11', 'web2py_uuid_locker', 'link-3');">web2py_uuid_locker</a></tt><tt class="py-op">.</tt><tt id="link-12" class="py-name" targets="Method web2py.gluon.newcron.Token.acquire()=web2py.gluon.newcron.Token-class.html#acquire"><a title="web2py.gluon.newcron.Token.acquire" class="py-name" href="#" onclick="return doclink('link-12', 'acquire', 'link-12');">acquire</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L69"></a><tt class="py-lineno">69</tt>  <tt class="py-line">    <tt class="py-keyword">try</tt><tt class="py-op">:</tt> </tt>
<a name="L70"></a><tt class="py-lineno">70</tt>  <tt class="py-line">        <tt class="py-name">bytes</tt> <tt class="py-op">=</tt> <tt class="py-op">[</tt><tt class="py-name">chr</tt><tt class="py-op">(</tt><tt id="link-13" class="py-name" targets="Function web2py.gluon.utils.rotate()=web2py.gluon.utils-module.html#rotate"><a title="web2py.gluon.utils.rotate" class="py-name" href="#" onclick="return doclink('link-13', 'rotate', 'link-13');">rotate</a></tt><tt class="py-op">(</tt><tt class="py-name">i</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> <tt class="py-keyword">for</tt> <tt class="py-name">i</tt> <tt class="py-keyword">in</tt> <tt class="py-name">range</tt><tt class="py-op">(</tt><tt class="py-number">16</tt><tt class="py-op">)</tt><tt class="py-op">]</tt> </tt>
<a name="L71"></a><tt class="py-lineno">71</tt>  <tt class="py-line">        <tt class="py-keyword">return</tt> <tt class="py-name">str</tt><tt class="py-op">(</tt><tt class="py-name">uuid</tt><tt class="py-op">.</tt><tt class="py-name">UUID</tt><tt class="py-op">(</tt><tt class="py-name">bytes</tt><tt class="py-op">=</tt><tt class="py-name">bytes</tt><tt class="py-op">,</tt> <tt class="py-name">version</tt><tt class="py-op">=</tt><tt class="py-number">4</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L72"></a><tt class="py-lineno">72</tt>  <tt class="py-line">    <tt class="py-keyword">finally</tt><tt class="py-op">:</tt> </tt>
<a name="L73"></a><tt class="py-lineno">73</tt>  <tt class="py-line">        <tt id="link-14" class="py-name"><a title="web2py.gluon.utils.web2py_uuid_locker" class="py-name" href="#" onclick="return doclink('link-14', 'web2py_uuid_locker', 'link-3');">web2py_uuid_locker</a></tt><tt class="py-op">.</tt><tt id="link-15" class="py-name" targets="Method web2py.gluon.newcron.Token.release()=web2py.gluon.newcron.Token-class.html#release"><a title="web2py.gluon.newcron.Token.release" class="py-name" href="#" onclick="return doclink('link-15', 'release', 'link-15');">release</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
</div><a name="L74"></a><tt class="py-lineno">74</tt>  <tt class="py-line"> </tt><script type="text/javascript">
<!--
expandto(location.href);
// -->
</script>
</pre>
<br />
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="web2py.gluon-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Project homepage -->
      <th class="navbar" align="right" width="100%">
        <table border="0" cellpadding="0" cellspacing="0">
          <tr><th class="navbar" align="center"
            ><a class="navbar" target="_top" href="http://www.web2py.com">web2py Web Framework</a></th>
          </tr></table></th>
  </tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
  <tr>
    <td align="left" class="footer">
    Generated by Epydoc 3.0beta1 on Wed Oct 13 19:44:41 2010
    </td>
    <td align="right" class="footer">
      <a href="http://epydoc.sourceforge.net">http://epydoc.sourceforge.net</a>
    </td>
  </tr>
</table>

<script type="text/javascript">
  <!--
  // Private objects are initially displayed (because if
  // javascript is turned off then we want them to be
  // visible); but by default, we want to hide them.  So hide
  // them unless we have a cookie that says to show them.
  checkCookie()
  // -->
</script>
  
</body>
</html>
